(navigation image)
Home American Libraries | Canadian Libraries | Universal Library | Community Texts | Project Gutenberg | Children's Library | Biodiversity Heritage Library | Additional Collections
Search: Advanced Search
Anonymous User (login or join us)
Upload
See other formats

Full text of "Arduino"

Keyless Lock Box 



i 



Make Projects 



build, hack, tweak, share, discover, J 



Keyless Lock Box 

Written By: Gordon McComb 



f TOOLS: 



Florist tape (putty) (1) 

Flush cutters (1) 
for wire 

Hacksaw (1) 

Hot glue gun and glue (1) 
low-temp glue recommended 

Needlenose pliers (1) 

Screwdriver (1) 

Solder (1) 

Soldering pencil (1) 

Step drill bit (1) 
e.g. 6" to 1 / 2 " 

drill with drill bits (1) 



© PARTS: 



Cigar box, or similar wooden box (1) 
Mine measured 8"x8"x1V 4 " 

Arduino Uno microcontroller board (1) 

ArduinolDEM) 

Optical finger navigation (OFN) module 



Pa 



'arallax #27903, parallax.com 

Power source (1) 

Plug-in power adapter or battery holder, 
eitiier 6xAA or 9v. If you prefer to use 
rechargeable NiCd or NiMH batteries, 
you need an 8xAA battery holder. 

Piezo Speaker (1) 

/ used BG Micro #AUD1 1 12. 

Parallax/Futaba servomotor (1) 
Parallax #900-00005 

Capacitor (1) 

resistors (2) 

Circuit board (1) 

RadioShack #276-168. radioshack.com 

Wire jumpers (1) 

/ like to use stranded wires; they're more 
flexible and less likely to break after 
repeated bending. 

Header (1) 

Header shells (16) 

aka crimp connector housings 

Cabled) 

for hobby servos 

PIvwnnH M^ 



© Make Projects 



www.makeprojects.com 



Page 1 of 1 6 



Keyless Lock Box 



\ - / 



or expanded PVC 
Brass strip (1) 

Machine screws (1) 

NutsM) 

Hookup wire (1) 

Heat-shrink tubing (1) 

Double-sided foam tape (1) 



SUMMARY 

That piggy bank is looking mighty low-tech these days, and you have to bash it open to get 
your cash. One piggy, one withdrawal. And then there are those cheesy, tin "Wild West" lock 
boxes with the red combination dial. Not only do they lack wow factor, your granny could 
crack one in 30 seconds. 

But stick an Arduino in a wooden box, along with a finger-operated sensor and small motor, 
and you've made a 21st-century treasure chest that's suitable for a daily diary, petty cash, 
or even those special Rice Krispies recipes that your snoopy neighbor wants to steal. 

There's no key in this keyless electronic combination lock box; you just move your finger 
across a small optical window, and it's "open sesame." The combination to the lock is a 
secret movement pattern only you know. 

How It Works 

The keyless lock box uses a unique optical finger navigation (OFN) sensor as a combination 
decoder. The OFN sensor works much like an optical mouse, except it's intended to be used 
in direct contact with your finger. They are used in handheld devices where a trackpad would 
be too large, but because they are more expensive than trackballs, they're not common in 
consumer products. 

Movement across the small surface of the sensor is converted to X and Y distance 
measurements — up, down, left, and right. Sequences of these movements make up the 
combination of the lock. 

For this project I'm using the Parallax OFN module, which puts a commercial OFN sensor 
on a breakout board that provides connectors for power (3.3V to 5V), ground, and 6 signal 
lines. The OFN module uses 2-wire I2C to communicate with a microcontroller, and has 

© Make Projects www.makeprojects.com Page 2 of 1 6 



Keyless Lock Box 

additional I/O pins for such things as the momentary pushbutton switch that engages when 
you push the optical sensor down. 

The locking mechanism uses a standard-size R/C servomotor that's glued into the bottom of 
the box. To lock the box, the turning servo engages a metal arm attached inside the box's 
lid. Turning the other way, it frees the bar, letting you open the lid. 

An Arduino microcontroller works as the main brain of the lock box, handling all the 
communications with the OFN module, controlling the servo, and even making musical tones 
on a small piezo speaker. 

For my box, I used a plain 8" square cigar box from a craft store — no need to smoke a 
bunch of stogies. The wood is unfinished; stain or paint to suit. You don't get Fort Knox with 
these boxes, but they'll keep out the casual thief. 



© Make Projects www.makeprojects.com Page 3 of 1 6 



Keyless Lock Box 





^" hole for plug 



Treasure box (top view) 



Optical finger 

navigation module 



3" 




Locking electronics take up left side 
of bo* (Arduino* OFN module, 
speaker, and servo) 



Left side view 



B ok rear 



Vk" hole for 

power plug 



D 



tower jack 
on Arduino 



1 



Arduino 



Top view Box rear 



Use these 

mounting 
holes 




OLD d " 



40 nylon nut 




] W nylon spacer 



CA 



4-40^3" 
Hat head 



• To make cutting and drilling easier, detach the box lid by removing the top screws in the 2 
hinges on the back. Use a hacksaw or razor saw to cut out a small chunk on the left side 
of the box for the OFN module, just wide enough to fit. Gently pry loose the knockout 
piece, being careful not to crack the bottom of the box. 

• Drill 1/8" mounting holes for the OFN module. To prevent the bit from pushing through and 
splintering the wood, press or clamp a piece of wood behind the hole while drilling. 

• Measure and mark the center of a 1/2" hole in the rear of the box, positioned so you can 
insert a barrel plug through the hole and into the Arduino's power jack. First drill a pilot 
hole with a 1/8" bit. Follow that with a 1/4" bit, and finish with a step bit, stopping at the 1/2" 
mark. 

• Referring to Image 2, temporarily position the Arduino in the rear left of the box, on top of 
1/8" nylon spacers. Make sure the Arduino power jack is in line with the rear hole you just 
drilled. Use a small nail or sharp pencil to mark the location for the 2 mounting holes 
indicated. Remove the Arduino and set aside. 



© Make Projects 



www.makeprojects.com 



Page 4 of 1 6 



Keyless Lock Box 





Locked 

(position 90) 




Unlocked 
(position 170) 




4-40x34' 
screw 



4-40 locking nut 






• Alignment of the locking parts is critical, so take this step slowly. Use a hacksaw to 
carefully remove the mounting flanges on both sides of the servo. Thread a 4-40x3/4" 
machine screw near the end of the included single-arm servo horn and use a 4-40 self- 
locking (nylon insert) nut to tightly secure the screw in place. 

• Attach the horn to the servo and slowly rotate the motor shaft to the center of movement. 
You'll make fine-tune adjustments later, so leave off the screw that holds the horn to the 
servo shaft. Use a hot glue gun to mount the servo in the front left corner of the box. 



© Make Projects 



www.makeprojects.com 



Page 5 of 1 6 



Keyless Lock Box 




2" 




Hot-glue to the 
top of the box 

after assembly 
and dry fitting 



3V$' 



t t 



4-40* fie" 

flat head 



OB 

4-40 nut 



LUI 



Mounting block 
Brass bar 




• To avoid unsightly screws on the top of the box, fasten the locking bar to a mounting block 
made of 1/4" aircraft-grade plywood or PVC inside the lid. The large surface area of the flat 
block will enable a strong glue joint. 

• Follow Image 1 to cut and drill a length of 1/2"-wide x 0.064"-thick brass strip, then cut the 
block to size, and drill holes matching those in the strip. Fasten the brass strip and block 
together with 4-40 flat-head machine screws. Bend down the front of the strip at a 15°-20° 
angle. You can adjust the angle later to achieve better locking action. 

• Stick a single 1/2" square piece of florist tape (putty) to the top of the block, and using 
your best guess, line up the locking bar so it engages with the screw attached to the servo 
horn. The putty keeps the mounting block in place until you can test the best placement on 
the lid. Reattach the lid to its hinges. 



© Make Projects 



www.makeprojects.com 



Page 6 of 1 6 



Keyless Lock Box 




Leave bare 6" M-M precrimped wire (need 9) 

V Snap on shell 



' r 




6" M-F precrimped wire (need 3) 

' r~ 




] <+- 



I I I 



(1) 



III 

Double-long breakaway 
header pins (1*3) 



I 



(IS) 

lxi header shell 



47pF tantalum capacitor 
(note the polarity marking!) 



Servo 
interconnect 



I I Solder at 
^j^/ base of pin 

1x3 header 




Sig V+ Gnd 



• Wiring makes or breaks a project. I used pre-crimped male/male and male/female 
jumpers, 1x1 header shells, and double-long breakaway header pins for robust and easily 
pluggable connections. 

• You could theoretically use the pin sides of 3 male/female jumpers to connect to the servo 
extension cable, but the double-long headers make a stronger friction-fit connection. Snap 
shells onto the jumpers to make 9 male/male jumpers with shells at one end, and 3 
male/female jumpers with shells on both ends. 

• I needed to add a bypass capacitor to reduce electrical noise from the servo that caused 
the Arduino to keep resetting itself. Solder a 47|iF tantalum capacitor between the middle 
and one side pin of a 3-pin double-long header. 

• Be absolutely sure that the + lead of the capacitor is connected to the center pin! These 
will connect to the servo's voltage (V+) and ground (Gnd) pins. 

• To calibrate the servo so that it points in the desired direction, download and unpack the 
project code , then verify (compile) and upload the ServoCalibrate sketch to your Arduino. 
Visit the same link for instructions on how to upload programs to an Arduino. 



© Make Projects 



www.makeprojects.com 



Page 7 of 1 6 



Keyless Lock Box 




DS 



Servo interconnect 



Don't mix 

these up! 



5V 
Gnd 




Arduinopins 



Servo wiring 



• Remove the horn from the shaft 
and plug in the 3-pin connector you 
just made, orienting the bypass cap 
on the black or brown wire (ground) 
side. Use 3 male/female jumpers to 
connect the servo and Arduino's 5V 
and ground together, and the 
servo's control (white or yellow) to 
Arduino digital pin 8. 

• Briefly depress the reset switch on 
the Arduino. When the 
ServoCalibrate sketch restarts, the 
servo first moves to its extremes, 
then centers itself at its midpoint 
and stops. After it's done, unplug 
the Arduino from the PC, then 
reattach the horn to the servo so 
that it points straight up, and 
secure it in position with the small 
included screw. 

• CAUTION! Warning! Whoa, 
Nellie! Do not cross the 
polarity of the wires or your servo 
may be permanently damaged. 




© Make Projects 



www.makeprojects.com 



Page 8 of 1 6 



Keyless Lock Box 





• To align the servo horn with the 
brass strip, reconnect the Arduino 
to your PC and upload the 
ServoLock sketch. 

• Thread the servo cable through the 
opening in the side of the box, 
manually move the servo arm 
toward the front of the box, and 
close the lid. 

• Click the reset button to run the 
sketch and listen for when the 
servo stops moving. Then test the 
lock by trying to lift the lid. 

• Should the servo horn and screw 
not properly engage over the brass 
strip — it makes clunking or 
scraping noises — pop the 
mounting block off the lid, 
reposition it, and try again. When 
you get the position just right, 
unplug the servo and mark around 
the block with a pencil for gluing 
later. 



© Make Projects 



www.makeprojects.com 



Page 9 of 1 6 



Keyless Lock Box 




K 



-H 



iw 





LV?" 
i - ±V2 ^ i 


-t-O O 
Set height to match holes in side of box 



Cut circuit board 
to size and drill ft" 

mounting holes 



Drill hole to 

break trace 



Tap power here 



RiadioShack 276-168 

perforated PCB 
(viewed from foil side) 

OFN module 

(mounted on 

other side) 



L 



Tap ground here 



Side view 



ill ^4 UH-IJ-l-f il l 



Tap signal lines here 






•• 



•• 



OFN 
module 



\ 



h- < X. Q +- h- 

n/i q -i x O O 

V Si#* v SLJ' *— ' ^i 

S !f !2 S 2? <n 



Clip off 
excess 



-/ 



-Circuit board 

Solder on 
this side 



• The OFN module doesn't have any 
direct means for mounting, so you 
need to solder it to a small circuit 
board that you can then attach to 
the side of the lock box using 4-40 
machine screws and nuts. Cut the 
board to size and drill 2 holes for 
mounting. 

• I used a board with component 
layout, in which long horizontal bus 
traces alternate with 3-hole vertical 
segments. This layout makes it 
easier for making wire connections 
on the backside of the board with 
the copper foil, which is necessary 
because the OFN module will take 
up all the space on the front. 

• Following the Step 7 diagram, drill 
a 1/8" hole in the middle of the long 
trace at the top, to break the 
connection. This will separate the 
voltage and ground connections to 
the OFN module, which is very 
important. 

• Then solder the OFN module to the 
board from the top, non-foil side 
(the leads will poke through to the 
foil side). Orient it with the LED on 
the drilled trace side, along with 
voltage and ground connections, 
and the 6 signal lines along the 
opposite side. 



© Make Projects 



www.makeprojects.com 



Page 10 of 16 



Keyless Lock Box 






jl lwuir.Hi!!i 1X^ 

i c ! .■ i-aii- '"*- -■*-. i 






*nSnnn^nV 


and 








h i,./:w::T: 
■ DSfBWft 






















m i-i i s::^ i 

■ CM--:ncrr5 




__ 






















VjU- - ' 


L E-taiiOc 


i 




? 





Cut eight 1" lengths of 1/8"-diameter heat-shrink tubing, and slip one each over 8 of your 
prepared male/female jumpers. Solder the bare pin end of each jumper to its corresponding 
connecting point on the foil side of the board 6 signal lines in a row, and the power and 
ground on the other side, as seen in the diagram. 

The pin will poke through; cut it flush with the front of the board after soldering. After all 
jumpers are soldered, push the heat-shrink tubing over the metal and apply heat to shrink. 

Mount the OFN module and board to the side of the box using 4-40 fasteners. 



© Make Projects 



www.makeprojects.com 



Page 11 of 16 



Keyless Lock Box 





Piezo speaker 



Solder here 



Snap on shell 
< — 




Arduino pin Dll 
Arduino pin D12 





Plug in the 8 jumpers from the OFN into the Arduino digital pins D2-D7 and analog pins 
A4-A5 as shown in Figure K. Be absolutely sure not to swap pins D6 and D7, or you'll 
reverse the power to the OFN and possibly damage it. 

Cut the remaining male/male jumper in half. Strip 1/8" of insulation from the cut ends, and 
solder them to the terminals of the piezo speaker. Use double-sided foam tape to mount 
the speaker to the bottom of the box, and attach the 2 jumpers to Arduino pins D1 1 and 
D12. The innards of your lock box should look like the 2nd image. 



© Make Projects 



www.makeprojects.com 



Page 12 of 16 



Keyless Lock Box 



Step 10 — Program it, 



© Make Projects www.makeprojects.com Page 1 3 of 1 6 



Keyless Lock Box 




• Reconnect your Arduino and then 
verify and upload the LockBox 
sketch. It includes several files in 
the same folder; make sure they 
remain in the folder or the sketch 
won't work. You need version 1 .0 
(or later) of the Arduino IDE, or the 
sketch will not compile. 

• For now, keep the lid open so you 
can see what happens when the 
box locks and unlocks. Keep the 
Arduino connected to the computer 
and open the Serial Monitor window 
(Tools menu) so you can review 
the debugging messages. 

• On Arduino startup or reset, the 
servo should go into lock (straight 
up) position, and you should see 
"Device ready" in the Serial Monitor 
window. If instead it reads, "Device 
not found," it means the Arduino 
can't find the OFN module, and you 
should recheck the wiring. 

• Swipe your finger across the 
sensor of the OFN module sensor, 
then press it down. You'll hear a 
series of tones indicating a bad 
combination entry. 

• Move your finger across the sensor 
again, this time using the pre- 
stored combination: Left- Right- Left. 
Click down the sensor, and this 
time the lock opens. After 7 
seconds the lock automatically 
closes. 



© Make Projects 



www.makeprojects.com 



Page 14 of 16 



Keyless Lock Box 

• See the comments in the LockBox 
sketch on where to change the 
combination. It can be any length 
sequence of swipes up, down, left, 
and right. Once the lock is 
reprogrammed, unplug the Arduino 
from your computer. Reattach the 
Arduino to the bottom of the lock 
box. 

• Now's a good time to glue the 
locking bar mounting plate 
permanently to the lid. Hot glue or 
wood glue works best. After the 
glue sets, stash your best secrets 
in your new keyless combination 
box. Whenever you need access, 
let your fingers unlock the 
mysteries within. 



Lock Box Power! 

The Keyless Lock Box is designed to use external power for unlocking, but it can sit in a locked 
state for indefinite periods without any power. To power the lock and open it, insert the plug into 
the hole in the back, enter the combination, then lift the lid. 

The box will automatically relock after 7 seconds. If the lid is still open, you can relock the box 
by manually pushing the servo arm toward the front of the box, pressing the Arduino's reset 
button, and closing the lid. When the sketch restarts, it automatically moves the servo to its lock 
position. You may then remove the power plug. 

If you forget the combination or can't get it to work, here's a "secret" override procedure that will 
briefly unlock the box: 

Unplug power to the Arduino. Press and hold down the OFN sensor while you plug the Arduino 
back in. Quickly open the lid when you hear the servo move to its unlock position. You'll have 
only 1 .5 seconds before the servo relocks the box. 

© Make Projects www.makeprojects.com Page 1 5 of 1 6 



Keyless Lock Box 

You can remove or comment out the override code in LockBox.ino if you don't want this 
behavior. 

Keep the box looking good by applying paint or finish to the bare wood, starting with a base coat, 
For a cleaner look, remove the clasp in front of the cigar box, and fill in the holes with wood 
putty. Sand for a smooth finish. Or replace the clasp with something fancier. 

This project first appeared in MAKE Volume 32 , page 110. 

This document was last generated on 201 3-02-08 06:57:38 PM. 



© Make Projects www.makeprojects.com Page 1 6 of 1 6